package com.ossjk.oa.accounting.mapper;

import java.util.List;

import com.ossjk.oa.accounting.vo.CwReceivablesVo;
import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ossjk.oa.accounting.entity.CwReceivables;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author chair
 * @since 2020-05-14
 */
public interface CwReceivablesMapper extends BaseMapper<CwReceivables> {
	List selectVoPage(Page page, @Param("ew") Wrapper wrapper);
	List<CwReceivablesVo> selectAllByMth(@Param("ew") Wrapper wrapper);
	@Select("select   left(max(needrecDate),7) from cw_receivables where needrecDate<(select min(needrecDate) from cw_receivables where left(needrecDate,7) = #{mth}) order by needrecDate desc")
	String selectPreMth(String mth);

	@Select("select   left(min(needrecDate),7) from cw_receivables where needrecDate>(select max(needrecDate) from cw_receivables where left(needrecDate,7) = #{mth}) order by needrecDate")
	String selectNextMth(String mth);

	//选定月份12个月以内的月份
	@Select("select a.cptMth  from (select DISTINCT left(needrecDate,7) as cptMth  from   cw_receivables ) a where  a.cptMth >#{mth} order by a.cptMth desc limit 0,12")
	String[] selectMax12Mth(String mth);

	@Select("SELECT count(id) FROM cw_receivables where left(needrecDate,7)=#{mth} ")
	Long countByMth(@Param("mth")String mth);
}
